/**
 * 
 */
package com.vector.ding.commons.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

/**
 * @author vector
 *
 */
public class StringUtil {
	
	public static final String EMPTY_STRING = "";
	
	public static final String DEFAULT_TS_FORMAT = "_yyyy_MM_dd_HH_mm_ss";
	public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd";
	public static final SimpleDateFormat defaultTsFormat = 
			new SimpleDateFormat(DEFAULT_TS_FORMAT);
	public static final SimpleDateFormat defaultDateFormat = 
			new SimpleDateFormat(DEFAULT_DATE_FORMAT);
	
	public static final boolean isEmpty(String string) {
		return null == string || string.isEmpty();
	}
	
	public static final boolean isNotEmpty(String string) {
		return !isEmpty(string);
	}
	
	public static final String getString(Object object) {
		if (null == object)
			return EMPTY_STRING;
		
		return object.toString();
	}
	
	public static final String wrapString(String string, String prefix, String suffix) {
		return prefix + string + suffix;
	}
	
	// 获得当前时间戳字符串
	public static final String getTimeStamp() {
		return defaultTsFormat.format(new Date());
	}
	
	// 获得默认的日期类型时间字符串
	public static final String getDateString() {
		return defaultDateFormat.format(new Date());
	}
	
	/**
	 * 获得指定日期的默认格式的时间字符
	 * @param date
	 * @return
	 * @see #DEFAULT_DATE_FORMAT
	 */
	public static final String getDateString(Date date) {
		return defaultDateFormat.format(date);
	}
	
	public static final String getUuid() {
		return UUID.randomUUID().toString();
	}
	
	public static final String removeString(String string, String removeString) {
		if (StringUtil.isEmpty(string))
			return string;
		
		return string.replaceAll(removeString, "");
	}

}
